<?php
/**
 * Created by PhpStorm.
 * User: s.utkin
 * Date: 03.12.2014
 * Time: 16:36
 */

namespace Users\Login\Helper;

use Users\TwitterConfig as Config;

trait Twitter {
	use \Pinenut\User\Auth\TwitterAuth;

	function config() {
		$config = Config::get ();
		$config ['redirectUrl'] = 'http://' . $_SERVER ['HTTP_HOST'] .
			$this->url ( 'users.login.twitter' );
		$this->config = $config;
		return $config;
	}

	function createAuth($data) {
		$finder = \Pinenut\User\OAuth2\Twitter::find();
		$finder->where('type', 'wtitter');
		$finder->where('id', $data->id_str);

		return $finder->one();
	}
} 